﻿using LocoyApp.Locoy.Entry;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LocoyApp.Locoy
{
    public class HrefPicker : LocoyCode
    {
        /// <summary>
        /// 执行方法，不能修改类和方法名称。
        /// </summary>
        /// <param name="content">标签内容</param>
        /// <param name="response">页面响应，包含了Url、原始Html等属性</param>
        /// <returns>返回处理后的标签内容</returns>
        public string Run(string content, ResponseEntry response)
        {
            var regex = new System.Text.RegularExpressions.Regex(@"href=""(.+?)""");
            var m = regex.Match(content);
            if (m.Success)
            {
                return m.Groups[1].Value.Trim();
            }

            return "";
        }
    }
}
